package my.jwds.p868;

public class BinaryGap {

    public static void main(String[] args) {

        Solution obj = new Solution();
        long start = System.currentTimeMillis();
        System.out.println(obj.binaryGap(3));
        System.out.println("运行时间:" + (System.currentTimeMillis() - start));
    }

    static class Solution {


        public int binaryGap(int n) {
            int max = 0,count = 1;
            while(n % 2 == 0){
                n>>=1;
            }
            n>>=1;
            while(n != 0){

                if (n%2==1){
                    max = Integer.max(max,count);
                    count=0;
                }
                n>>=1;
                count++;
            }
            return max;

        }


    }
}